﻿@{
    ViewBag.Title = "PersistentChat";
}
<h2>PersistentConnection</h2>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.signalR-1.1.2.min.js"></script>

<script src="~/signalr/hubs" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        var connection = $.connection('/echo');

        connection.received(function (data) {
            $('#messages').append('<li>' + data + '</li>');
        });
        connection.start();
        $("#broadcast").click(function () {
            connection.send($('#msg').val());
        });
        $("#btnStop").click(function () {
            connection.stop();
        });
    });

</script>
<h2>@ViewBag.Message</h2>
<input type="text" id="msg" />
<input type="button" id="broadcast" value="发送" />
<input type="button" id="btnStop" value="退出/断开链接" />
<ul id="messages">
</ul>
<div>
    <h3>当前在线用户列表</h3>
    <ul id="userList">
        <li></li>
    </ul>
</div>
